﻿//===============================================================================
// TREASURY MANAGMENT INFORMATION SYSTEMS 
// COMMON DATA CLASS
//===============================================================================
// Copyright © TIMS GROUP. 2008
//===============================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using APPLICATION.DataAccess.TIMSDataSetTableAdapters;
using APPLICATION.DataAccess.TimsDSTableAdapters;

namespace APPLICATION.DataAccess
{
    class dbStaff
    {

        public  DataTable getStaffDatatable()
        {

           dtPostTableAdapter dtPosts = new dtPostTableAdapter();
           DataTable dt =  dtPosts.GetData();

           return dt;
        }


        public void insertUpdateStaff(int StafID,int depId,int postid,int cityId,String name,String address,bool gender,DateTime dborn,DateTime dwork,string perNum,int tabnum)
        {
            int? stafid;
            dtStaffTableAdapter dtStaff = new dtStaffTableAdapter();
            
        }


        /// <summary>
        /// INSERT UPDATE DELETE FOR STAFF
        /// </summary>
        /// <returns> ??? Not complete </returns>
        /// <remarks> INSERT(0),UPDATE(1),DELETE(2) </remarks>

     public void InsertUpdateDeleteStaff(int Action, int StaffID, int DepID, int PostID, int CityID, string StaffName, string addr, 
            bool Gender, DateTime DBorn, DateTime DWork, String PerNum,int TabNum)
        {
                SqlConnection connection = new SqlConnection(globals.APPCONNSTRING);

                SqlCommand command = new SqlCommand();
                command.Connection = connection;

                command.CommandText = "tsp_dtStaff";
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.Add("@Action",   SqlDbType.TinyInt).Value = Action;        // ActionID insert update delete
                command.Parameters.Add("@StaffID",  SqlDbType.Int).Value = StaffID;           // Staff ID 
                command.Parameters.Add("@DepID",    SqlDbType.Int).Value = DepID;             // Department ID
                command.Parameters.Add("@PostID",   SqlDbType.Int).Value= PostID;             // Post ID 
                command.Parameters.Add("@CityID",   SqlDbType.Int).Value = CityID;            // City ID
                command.Parameters.Add("@StaffName", SqlDbType.NVarChar).Value = StaffName;   // Staff Name Surname
                command.Parameters.Add("@addr",     SqlDbType.NVarChar,100).Value = addr;     // Adress 
                command.Parameters.Add("@Gender",   SqlDbType.Bit).Value = Gender;            // Gender Male Female
                command.Parameters.Add("@DBorn",    SqlDbType.SmallDateTime).Value = DBorn;   // BirthDate 
                command.Parameters.Add("@DWork",    SqlDbType.SmallDateTime).Value = DWork;   // Work Date
                command.Parameters.Add("@PerNum",   SqlDbType.NChar, 20).Value = PerNum;      // Pesronal Pasport Number
                command.Parameters.Add("@TabNum",   SqlDbType.Int).Value = TabNum;            // Table Number

                try
                {

                    connection.Open();
                    command.ExecuteNonQuery(); //Should be removed in trye catch block ! Leaved for testing 

                } catch (Exception ex) {
                    
                   
                }
                
         

                connection.Close();
       }



   
    }
}
